import { defineStore } from 'pinia'
import { ref } from 'vue'
import {getAddresses} from '@/apis/order'

export const useOrderStore = defineStore('order', () => {
  const addresses = ref([])

  // 获取收货地址列表
  const findAddresses = async () => {
    try {
      const res = await getAddresses()
      if (res.code === '0') {
        addresses.value = res.data.records
      }
      return res
    } catch (error) {
      throw error
    }
  }

  return {
    addresses,
    findAddresses
  }
}) 